import java.util.Scanner;

public class Bill {
    public static int[] starttime = new int[3];
    public static int[] endtime = new int[3];
    public static int[] poortime = new int[3];
    public static int time;
    public static float money;
    public static int year;
    public static int month;
    public static int day;
    public static int T = 0;
    public static int W = 1;
    public static int M = 1;
    public static void main(String []args){
        Scanner input=new Scanner(System.in);
        System.out.println("开始年月日:");
        year = input.nextInt();
        month = input.nextInt();
        day = input.nextInt();
        System.out.println("开始时间:");
        for(int i = 0;i < 3;i++){
            starttime[i] = input.nextInt();
        }
        System.out.println("结束时间:");
        for(int i = 0;i < 3;i++){
            endtime[i] = input.nextInt();
        }
        Date();
        Time();
        if(M == 0){
            System.out.println("时间是否经过变化了（是：1；否：0）");
            int n = input.nextInt();
            if(n == 1){
                time = time + 60;
            }
        }
        Money();
        System.out.println("话费为" + money + "美元.");
    }
    public static void Date(){
        if(month == 1 || month == 2)
        {
            year--;
            month += 12;
        }
        W = (day + 2 * month + 3 * (month + 1)/5 + year + year/4 - year/100 + year/400 + 1) % 7;//0是周日，其他对应
        if(month > 12)
        {
            year++;
            month -= 12;
        }
        if(W == 0){
            if(month == 3 && day >=25 && day <= 31){
                T = 1;
            }
            else if(month == 10 && day >=25 && day <= 31){
                T = 2;
            }
            else T = 0;
        }
        else T = 0;
    }
    public static void Time(){
        if(starttime[0] > endtime[0]){
            endtime[0] += 24;
        }
        for(int i = 0;i < 3;i++){
            poortime[i] = endtime[i] - starttime[i];
        }
        if(T == 0){
            if(W == 6 && endtime[0] >= 27){
                if(month == 3 && day >=24 && day <= 30){
                    poortime[0]--;
                }
                else if(month == 10 && day >=25 && day <= 31){
                    poortime[0]++;
                }
            }
            else if(W == 6 && endtime[0] >= 26 && endtime[0] <= 27 && month == 10 && day >=25 && day <= 31){
                M = 0;//判断时间是否经过变化了的
            }
        }
        else if(T == 1){
            if(starttime[0] <= 2 && endtime[0] >= 3){
                poortime[0]--;
            }
        }
        else if(T == 2){
            if(starttime[0] < 2 && endtime[0] >= 3){
                poortime[0]++;
            }
            else if(poortime[1] < 0 && starttime[0] == 2 && endtime[0] == 2){
                poortime[0]++;
            }
            else if(starttime[0] <= 2 && endtime[0] == 2){
                M = 0;//判断时间是否经过变化了的
            }
            else if(starttime[0] == 2  && endtime[0] > 2){
                M = 0;//判断时间是否经过变化了的
            }
        }
        time = poortime[0] * 60 + poortime[1];
        if(poortime[2] > 0){//为负数或0时不像前进，为正确值
            time++;
        }
    }
    public static void Money(){
        if(time <= 20){
            money = (float)(time * 0.05);
        }
        else{
            money =  (float) (1 + (time - 20) * 0.10);
        }
    }
}

